<?php defined('SMIT_PATH') or die('Access Denied');
/**
 *	handlers/forum.php - forum functions handler
 *	This is Smit Matterhorn - Build 24109
 *	
 *
 * @author		The SmitBoard Team & Community
 * @license		GNU GPL v3
 * @link		http://smitboard.sf.net
 * @since		Matterhorn
 */
 
class ForumHandler
{
	public $base;
	public $db;
	
	public $cache = array();

	public function __construct()
	{
		$this->base = SmitBase::getInstance();
		$this->db = &$this->base->db;
	}

	public function get_all_forums()
	{
		if(!isset($this->cache['forums']))
		{
			$this->cache['forums'] = $this->db->select()->from('forums')->run()->result(NULL, 1);
		}
		return $this->cache['forums'];
	}

	public function get_forum_by_id($id)
	{
		if(!isset($this->cache['forum_' . $id]))
		{
			$this->cache['forum_' . $id] = $this->db->select()->from('forums')->where('id', intval($id))->run()->row();
		}
		return $this->cache['forum_' . $id];
	}
	
	public function get_forums_by_parent($parent)
	{
		if(!isset($this->cache['childset_' . $parent]))
		{
			$this->cache['childset_' . $parent] = $this->db->select()->from('forums')->where('parent', intval($parent))->run()->result(NULL, 1);
		}
		return $this->cache['childset_' . $parent];
	}

    public function check_forum_password($password)
	{
		
	}
}

?>